class Solution:
  def findSum(self, arr: list, n: int) -> tuple:
    arr.sort()
    i, j = 0, len(arr)-1
    while i < j:
      while i < j and arr[i] + arr[j] < n:
        i = i + 1
      while i < j and arr[i] + arr[j] > n:
        j = j - 1
      if arr[i] + arr[j] == n:
        return (arr[i], arr[j])
    return (-1, -1)
  
  def findSumByHashMap(self, arr: list, n: int) -> tuple:
    hash_map = dict()
    for i in range(len(arr)):
      hash_map[i] = arr[i]
    for i in range(len(arr)):
      another = n - arr[i]
      if another in hash_map and another != arr[i]:
        return ((arr[i], another))
    return (-1, -1)


if __name__ == "__main__":
  arr = [1, 6, 4, 7, 3]
  solution = Solution()
  print(solution.findSumByHashMap(arr, 4))
